package com.candy.listener;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class ApplicationListener implements ServletContextListener, ServletContextAttributeListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("Application初始化");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("Application销毁");
    }

    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println("Application作用域中的数据新增，"+event.getName()+":"+event.getValue());
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println("Application作用域中的数据移除，"+event.getName()+":"+event.getValue());
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println("Application作用域中的数据更新，"+event.getName()+":"+event.getValue());
    }
}
